/**
 * Created by zqk on 2018/5/16.
 */
$(document).ready(function () {
    var form = new xhForm($('#xh_form'));
    var iTestId=addressUri.getParam('iTestId');
    var iProjectId=addressUri.getParam('iProjectId');
    form.parse();
    form.bindRequired($('#bt_modal_confirm',parent.document));
    if(iTestId!=null){ //edit
        $.ajax({
            url:moduleUrl+'test/getTestInfo',
            data:{iTestId:iTestId},
            type:'POST',
            dataType:'json',
            success:function (data) {
                form.fill(data);
            },
            error:function (data) {
                console.log(data);
            }
        });
    }
    $('#bt_modal_confirm',parent.document).click(function () {
        $.ajax({
            url:moduleUrl+'test/saveTest?iProjectId='+iProjectId,
            data:$('#xh_form').serialize(),
            type:'POST',
            success:function (data) {
                window.top.xhTop.showSuccess(
                  data.msg
                );
                window.top.xhTop.getActiveFrame().testList.datagrid('reload');
                // window.top.xhTop.getActiveFrame().caseList.datagrid('reload');
                window.top.xhTop.closeModal();
            },
            error:function (data) {
                window.top.xhTop.showError(
                    data.responseJSON.error,
                    data.responseJSON.msg
                );
            }
        });
    });
    // modalBind.bindClick();

});